package org.yoao.crm.tools;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

/**
 * @author yxwonline.com
 * @description 
 * @date 2010-8-2 下午10:46:54
 */
public class FileTool {
	
	private String path = null;
	
	public FileTool(String path){
		this.path = path;
	}
	public boolean exists(){
		try{
			if(new File(path).exists())
				return true;
			else return false;
		}
		catch(Exception e){
			e.printStackTrace();
			return false;
		}
	}
	
	public boolean create(){
		try{
			File file = new File(path);
			return file.createNewFile();
		} catch (Exception e) {
			e.printStackTrace();
			return false;	
		}
	}
	
	public static String getFileContent(String path){
		try {
			File file = new File(path);
			if(!file.exists()) return "文件不存在["+path+"]";
			FileReader fileReader = new FileReader(file);
	        BufferedReader br = new BufferedReader(fileReader);
	        String result;
	        while((result = br.readLine()) != null){
	        	System.out.println(result);
	        }
	        fileReader.close();
	        br.close();
	        return result;
		} catch (Exception e) {
			System.out.println(e);
			return "文件获取失败["+e.getMessage()+"]";
		}
	}
}
